package cn.smxy.college.controller;

import cn.smxy.college.service.CollegePlantService;
import cn.smxy.param.CollegePlantPageParam;
import cn.smxy.param.PageParam;
import cn.smxy.pojo.CollegePlant;
import cn.smxy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/college/plant")
public class CollegePlantController {

    @Autowired
    private CollegePlantService collegePlantService;

    /**
     * 保存校园植物作品接口
     * @param collegePlant
     * @return
     */
    @PostMapping("/save")
    public R save(@RequestBody CollegePlant collegePlant) {
        return collegePlantService.save(collegePlant);
    }

    /**
     * 分页展示校园植物接口
     * @param collegePlantPageParam
     * @return
     */
    @PostMapping("/page")
    public R page(@RequestBody CollegePlantPageParam collegePlantPageParam) {
        return collegePlantService.page(collegePlantPageParam);
    }

    /**
     * 查看植物校园信息接口
     * @param plantId
     * @return
     */
    @GetMapping("/info/{plantId}")
    public R info(@PathVariable Long plantId) {
        return collegePlantService.info(plantId);
    }

    // TODO:管理员模块

    /**
     * 删除校园植物接口
     * @param plantId
     * @return
     */
    @DeleteMapping("/remove/{plantId}")
    public R removePlant(@PathVariable Long plantId) {
        return collegePlantService.removePlant(plantId);
    }

    /**
     * 删除用户对应的校园植物接口
     * @param userId
     * @return
     */
    @DeleteMapping("/remove/user/{userId}")
    public R removeByUserId(@PathVariable Long userId) {
        return collegePlantService.removeByUserId(userId);
    }


}
